﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="RecordProcessor.cs" company="DHGMS Solutions">
//   Copyright 2004-2014 DHGMS Solutions.
//      
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//      
//   http://www.apache.org/licenses/LICENSE-2.0
//      
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
// </copyright>
// <summary>
//   Job Result for Record Processing
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Dhgms.TplHelper.Model.Info.JobResult
{
    using System;
    using System.Collections.Generic;
    using System.Net.Mail;

    /// <summary>
    /// Job Result for Record Processing
    /// </summary>
    public class RecordProcessor : Base
    {
        #region Constants and Fields

        /// <summary>
        /// Timestamp for when the job finished
        /// </summary>
        public DateTime Finished;

        /// <summary>
        /// Timestamp for when the job started
        /// </summary>
        public DateTime Started;

        /// <summary>
        /// List of task results for the job
        /// </summary>
        public List<TaskResult.RecordProcessor> TaskResults;

        #endregion

        /*
        public override string GetEmailBody()
        {
            System.Text.StringBuilder sb = new StringBuilder();

            sb.AppendLine("<table>");
            sb.AppendLine("<tr><td>Started</td><td>" + Started.ToString() + "</td></tr>");
            sb.AppendLine("<tr><td>Finished</td><td>" + Finished.ToString() + "</td></tr>");
            sb.AppendLine("</table>");
            if (TaskResults != null)
            {
                sb.AppendLine("<h2>Tasks</h2>");
                sb.AppendLine("<table>");
                foreach (Model.Info.TaskResult.RecordProcessor taskResult in TaskResults)
                {
                    sb.AppendLine("<tr>");
                    sb.AppendLine("<td>" + taskResult.Name + "</td>");
                    sb.AppendLine("<td>" + taskResult.Started + "</td>");
                    sb.AppendLine("<td>" + taskResult.Finished + "</td>");
                    sb.AppendLine("<td>" + taskResult.RecordsProcessed + "</td>");
                    sb.AppendLine("</tr>");
                }
                sb.AppendLine("</table>");
            }

            return sb.ToString();
        }
         * */
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="RecordProcessor"/> class. 
        /// </summary>
        public RecordProcessor()
            : base(null)
        {
            this.TaskResults = new List<TaskResult.RecordProcessor>();
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="RecordProcessor"/> class. 
        /// </summary>
        /// <param name="emailRecipients">
        /// Email Recipients for the report
        /// </param>
        /// <param name="started">
        /// When the job started
        /// </param>
        /// <param name="finished">
        /// When the job finished
        /// </param>
        /// <param name="taskResults">
        /// Results of Tasks
        /// </param>
        public RecordProcessor(
            MailAddressCollection emailRecipients, 
            DateTime started, 
            DateTime finished, 
            List<TaskResult.RecordProcessor> taskResults)
            : base(emailRecipients)
        {
            this.TaskResults = new List<TaskResult.RecordProcessor>();
            this.Started = started;
            this.Finished = finished;
            this.TaskResults = taskResults;
        }

        #endregion
    }
}